module.exports = app => {
  const { router, controller } = app
  router.get('/test', controller.test.index)

  // 注册登录
  router.post('/api/v1/signup', controller.user.signup)
  router.post('/api/v1/signin', controller.user.signin)
  router.get('/api/v1/signout', controller.user.signout)
  router.post('/api/v1/signin/wxchat', controller.user.signinWxchat)

  // 用户信息
  router.get('/api/v1/user/:_id', controller.user.findUser)
  router.put('/api/v1/updateuser', controller.user.updateUser)
  router.put('/api/v1/user/:_id', controller.user.update)
  router.delete('/api/v1/logoff', controller.user.logOff)
  router.delete('/api/v1/deleteuser', controller.user.deleteUser)

  // 轮播图管理
  router.get('/api/v1/swiper', controller.swiper.list)
  router.post('/api/v1/swiper', controller.swiper.create)
  router.put('/api/v1/swiper/:_id', controller.swiper.update)
  router.delete('/api/v1/swiper/:_id', controller.swiper.delete)

  // 分类管理
  router.get('/api/v1/category', controller.category.list)
  router.post('/api/v1/category', controller.category.create)
  router.put('/api/v1/category/:_id', controller.category.update)
  router.delete('/api/v1/category/:_id', controller.category.delete)

  // 故事主题管理
  router.get('/api/v1/storytheme', controller.storytheme.list)
  router.get('/api/v1/storytheme/:_id', controller.storytheme.findTheme)
  router.get(
    '/api/v1/storytheme/category/:_id',
    controller.storytheme.getByCategoryId
  )
  router.post('/api/v1/storytheme', controller.storytheme.create)
  router.put('/api/v1/storytheme/:_id', controller.storytheme.update)
  router.delete('/api/v1/storytheme/:_id', controller.storytheme.delete)

  // 故事管理
  router.get('/api/v1/story', controller.story.list)
  router.get('/api/v1/story/theme/:_id', controller.story.findBythemeId)
  router.post('/api/v1/story', controller.story.create)
  router.put('/api/v1/story/:_id', controller.story.update)
  router.put('/api/v1/story/like/:_id', controller.story.updateLikeList)
  router.put('/api/v1/story/comment/:_id', controller.story.updateCommentList)
  router.delete('/api/v1/story/:_id', controller.story.delete)

  // 上传文件
  router.get('/api/v1/upload/token', controller.upload.uploadAction)
}
